﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Windows;
using System.Windows.Controls;
using SilveR.RService;

namespace SilveR
{
    public partial class ValidationMessagesWindow : ChildWindow
    {
        public ValidationMessagesWindow(List<string> validationResults)
        {
            InitializeComponent();
            this.Title = "Data Validation Warnings";
            txtHeader.Text = "The follow data validation warnings were generated:";
            txtQuestion.Text = "After considering the above warnings, do you want to continue with the analysis?";

            string message = null;
            foreach (string s in validationResults)
            {
                message = s + Environment.NewLine;
            }

            txtWarnings.Text = message;
        }

        public ValidationMessagesWindow(List<ValidationResult> validationResults)
        {
            InitializeComponent();
            this.Title = "GUI Validation Errors";
            txtHeader.Text = "Please fix the following errors on the form:";

            string message = null;
            foreach (var v in validationResults)
            {
                message = message + v.ErrorMessage + Environment.NewLine;
            }

            txtWarnings.Text = message;

            btnCancel.Visibility = System.Windows.Visibility.Collapsed;
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}